package com.adam.framework.db.page;

import javax.sql.RowSet;
import java.sql.ResultSet;
import java.sql.SQLException;

public class PagedStatementMysqlImpl extends PagedStatement {
    public PagedStatementMysqlImpl(String sql){
        super(sql);
    }

    public PagedStatementMysqlImpl(String sql, int pageNo){
        super(sql, pageNo);
    }

    public PagedStatementMysqlImpl(String sql, int pageNo, int pageSize){
        super(sql, pageNo, pageSize);
    }

    protected String intiQuerySQL(String sql, int startIndex, int size){
        StringBuffer querySQL = new StringBuffer();
        if (size != super.MAX_PAGE_SIZE) {
            querySQL.append(  sql)
                    .append(" LIMIT ").append(startIndex)
                    .append(" , ").append(startIndex + size);
        } else {
            querySQL.append(  sql)
                    .append(" LIMIT ").append(startIndex);

        }
        return querySQL.toString();
    }

    protected  RowSet populate(ResultSet rs) throws SQLException{
        //OracleCachedRowSet ocrs = new OracleCachedRowSet();
        //ocrs.populate(rs);
        return null;
    }
}
